home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWCollectable - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss typedef RWCollectable Object; // Smalltalk typedef #include <rw/collect.h> DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee is an abstract base class for collectable objects. This class contains virtual functions for identifying, hashing, comparing, storing and retrieving collectable objects. While these virtual functions have simple default definitions, objects that inherit this base class will typically redefine one or more of them. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Polymorphic VVVViiiirrrrttttuuuuaaaallll FFFFuuuunnnnccccttttiiiioooonnnnssss virtual ~~~~RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee(); All functions that inherit class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee have virtual destructors. This allows them to be deleted by such member functions as rrrreeeemmmmoooovvvveeeeAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(((()))) without knowing their type. virtual RWspace bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const; Returns the number of bytes used by the virtual function ssssaaaavvvveeeeGGGGuuuuttttssss((((RRRRWWWWFFFFiiiilllleeee&&&&)))) to store an object. Typically, this involves adding up the space required to store all primitives, plus the results of calling rrrreeeeccccuuuurrrrssssiiiivvvveeeeSSSSttttoooorrrreeeeSSSSiiiizzzzeeee(((()))) for all objects inheriting from RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. See the TTTToooooooollll....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee Section entitled "Virtual Function binaryStoreSize" for details. virtual int ccccoooommmmppppaaaarrrreeeeTTTToooo(const RWCollectable*) const; The function ccccoooommmmppppaaaarrrreeeeTTTToooo(((()))) is necessary to sort the items in a collection. If pppp1111 and pppp2222 are pointers to RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee objects, the statement pppp1111---- >>>>ccccoooommmmppppaaaarrrreeeeTTTToooo((((pppp2222))));;;; should return: 0 if ****pppp1111 "is equal to" ****pppp2222; >0 if ****pppp1111 is "larger" than ****pppp2222; PPPPaaaaggggeeee 1111 RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) <0 if ****pppp1111 is "smaller" than ****pppp2222. Note that the meaning of "is equal to," "larger" and "smaller" is left to the user. The default definition provided by the base class is based on the addresses, i.e., rrrreeeettttuuuurrrrnnnn tttthhhhiiiissss ======== pppp2222 ???? 0000 :::: ((((tttthhhhiiiissss >>>> pppp2222 ???? 1111 :::: ----1111))));;;; and is probably not very useful. virtual unsigned hhhhaaaasssshhhh() const; Returns a hash value. This function is necessary for collection classes that use hash table look-up. The default definition provided by the base class hashes the object's address: rrrreeeettttuuuurrrrnnnn ((((uuuunnnnssssiiiiggggnnnneeeedddd))))tttthhhhiiiissss;;;; It is important that the hash value be the same for all objects which return TTTTRRRRUUUUEEEE to iiiissssEEEEqqqquuuuaaaallll(((()))). virtual RWClassID iiiissssAAAA() const; Returns a class identification number (typedef'd to be an uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt). The default definition returns ________RRRRWWWWCCCCOOOOLLLLLLLLEEEECCCCTTTTAAAABBBBLLLLEEEE. Identification numbers greater than or equal to 0x8000 (hex) are reserved for Rogue Wave objects. User defined classes should define iiiissssAAAA() to return a number between 0 and 0x7FFF. virtual RWBoolean iiiissssEEEEqqqquuuuaaaallll(const RWCollectable* t) const; Returns TTTTRRRRUUUUEEEE if collectable object "matches" object at address tttt. The default definition is: rrrreeeettttuuuurrrrnnnn tttthhhhiiiissss ======== tttt;;;; iiii....eeee...., both objects have the same address (a test for iiiiddddeeeennnnttttiiiittttyyyy). The definition may be redefined in any consistent way. virtual RWCollectable* nnnneeeewwwwSSSSppppeeeecccciiiieeeessss() const; Allocates a new object off the heap of the same type as self and returns a pointer to it. You are responsible for deleting the object when done with it. virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWFile&); Read an object's state from a binary file, using class RRRRWWWWFFFFiiiilllleeee, replacing the previous state. PPPPaaaaggggeeee 2222 RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWvistream&); Read an object's state from an input stream, replacing the previous state. virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWFile&) const; Write an object's state to a binary file, using class RRRRWWWWFFFFiiiilllleeee. virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWvostream&) const; Write an object's state to an output stream. RWStringID ssssttttrrrriiiinnnnggggIIIIDDDD(); Returns the identification string for the class. Acts virtual, although it is not. RWspace rrrreeeeccccuuuurrrrssssiiiivvvveeeeSSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const; Returns the number of bytes required to store the object using the global operator RWFile& operator<<(RWFile&, const RWCollectable&); Recursively calls bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee(((()))), taking duplicate objects into account. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss static RWClassID ccccllllaaaassssssssIIIIDDDD(const RWStringID& name); Returns the result of looking up the RRRRWWWWCCCCllllaaaassssssssIIIIDDDD associated with nnnnaaaammmmeeee in the global RWFactory. PPPPaaaaggggeeee 3333 RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) static RWClassID ccccllllaaaassssssssIIIIssssAAAA(); Returns the RRRRWWWWCCCCllllaaaassssssssIIIIDDDD of this class. static RWBoolean iiiissssAAAAttttoooommmm(RWClassID id); Returns TTTTRRRRUUUUEEEE if iiiidddd is the RRRRWWWWCCCCllllaaaassssssssIIIIDDDD that is associated with an RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee class that has a programmer-chosen RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD. static RWspace nnnniiiillllSSSSttttoooorrrreeeeSSSSiiiizzzzeeee(); Returns the number of bytes required to store a rrrrwwwwnnnniiiillll pointer in an RRRRWWWWFFFFiiiilllleeee. RRRReeeellllaaaatttteeeedddd GGGGlllloooobbbbaaaallll OOOOppppeeeerrrraaaattttoooorrrrssss RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream&, const RWCollectable& obj); RWFile& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile&, const RWCollectable& obj); Saves the object oooobbbbjjjj to a virtual stream or RRRRWWWWFFFFiiiilllleeee, respectively. Recursively calls the virtual function ssssaaaavvvveeeeGGGGuuuuttttssss(((()))), taking duplicate objects into account. See the TTTToooooooollllssss....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee section entitled "Persistence" for more information. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream&, RWCollectable& obj); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile&, RWCollectable& obj); Restores an object inheriting from RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee into oooobbbbjjjj from a virtual stream or RRRRWWWWFFFFiiiilllleeee, respectively, replacing the previous contents of oooobbbbjjjj. Recursively calls the virtual function rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(((()))), taking duplicate objects into account. See the TTTToooooooollllssss....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee section entitled "Persistence" for more information. Various exceptions that could be thrown are RRRRWWWWIIIInnnntttteeeerrrrnnnnaaaallllEEEErrrrrrrr (if the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy does not know how to make the object), and RRRRWWWWEEEExxxxtttteeeerrrrnnnnaaaallllEEEErrrrrrrr (corrupted stream or file). RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream&, RWCollectable*& obj); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile&, RWCollectable*& obj); PPPPaaaaggggeeee 4444 RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee((((3333CCCC++++++++)))) Looks at the next object on the input stream or RRRRWWWWFFFFiiiilllleeee, respectively, and either creates a new object of the proper type off the heap and returns a pointer to it, or else returns a pointer to a previously read instance. Recursively calls the virtual function rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(((()))), taking duplicate objects into account. If an object is created off the heap, then you are responsible for deleting it. See the TTTToooooooollllssss....hhhh++++++++ UUUUsssseeeerrrr''''ssss GGGGuuuuiiiiddddeeee section entitled "Persistence" for more information. Various exceptions that could be thrown are RRRRWWWWIIIInnnntttteeeerrrrnnnnaaaallllEEEErrrrrrrr (if the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy does not know how to make the object), and RRRRWWWWEEEExxxxtttteeeerrrrnnnnaaaallllEEEErrrrrrrr (corrupted stream or file). In case an exception is thrown during this call, the pointer to the partly restored object will probably be lost, and memory will leak. For this reason, you may prefer to use the static methods ttttrrrryyyyRRRReeeeccccuuuurrrrssssiiiivvvveeeeRRRReeeessssttttoooorrrreeee(((()))) documented above. PPPPaaaaggggeeee 5555